from alg import Solution
import time
import ast

def load_test_cases(filename="test_cases.txt"):
    """
    从文件加载测试用例
    """
    test_cases = []
    with open(filename, "r") as f:
        for line in f:
            # 将字符串形式的列表转换为实际的列表
            test_cases.append(ast.literal_eval(line.strip()))
    return test_cases

def run_tests():
    """
    运行测试用例
    """
    solution = Solution()
    test_cases = load_test_cases()
    
    print("开始测试...")
    print("-" * 50)
    
    for i, case in enumerate(test_cases, 1):
        start_time = time.time()
        result = solution.candy(case)
        end_time = time.time()
        
        print(f"测试用例 {i}:")
        print(f"输入: {case}")
        print(f"输出: {result}")
        print(f"运行时间: {(end_time - start_time)*1000:.2f}ms")
        print("-" * 50)

if __name__ == "__main__":
    run_tests() 